home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue50 / IPC / Messages / CustomMsgU.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-08-31  |  1.4 KB  |  64 lines

  1. unit CustomMsgU;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows;
  7.  
  8. type
  9.   TBroadcastSystemMsgFunc = function (Flags: DWORD; Recipients: PDWORD;
  10.     uiMessage: UINT; wParam: WPARAM; lParam: LPARAM): Longint; stdcall;
  11.  
  12. var
  13.   wm_ClinicMessage: UInt;
  14.   BroadcastSystemMsg: TBroadcastSystemMsgFunc;
  15.  
  16. implementation
  17.  
  18. uses
  19.   SysUtils;
  20.  
  21. {$ifdef Ver90}
  22. //These variables did not exist until Delphi 3
  23. var
  24.   Win32Platform: Integer = 0;
  25.   Win32MajorVersion: Integer = 0;
  26.   Win32MinorVersion: Integer = 0;
  27.  
  28. procedure InitPlatformId;
  29. var
  30.   OSVersionInfo: TOSVersionInfo;
  31. begin
  32.   OSVersionInfo.dwOSVersionInfoSize := SizeOf(OSVersionInfo);
  33.   if GetVersionEx(OSVersionInfo) then
  34.     with OSVersionInfo do
  35.     begin
  36.       Win32Platform := dwPlatformId;
  37.       Win32MajorVersion := dwMajorVersion;
  38.       Win32MinorVersion := dwMinorVersion;
  39.     end;
  40. end;
  41. {$endif}
  42.  
  43. procedure InitBroadcastMsgPtr;
  44. const
  45.   APIName: array[Boolean] of PChar =
  46.     ('BroadcastSystemMessageA', 'BroadcastSystemMessage');
  47. var
  48.   InWin95: Boolean;
  49. begin
  50.   //Running under Windows 95?
  51.   InWin95 := (Win32Platform = VER_PLATFORM_WIN32_WINDOWS) and
  52.              (Win32MajorVersion = 4) and (Win32MinorVersion = 0);
  53.   @BroadcastSystemMsg :=
  54.     GetProcAddress(GetModuleHandle(Windows.User32), APIName[InWin95])
  55. end;
  56.  
  57. initialization
  58.   wm_ClinicMessage := RegisterWindowMessage('MyUniqueString!!!');
  59. {$ifdef Ver90}
  60.   InitPlatformId;
  61. {$endif}
  62.   InitBroadcastMsgPtr
  63. end.
  64.